<?php

namespace app\mobile\controller;

use app\common\model\CardCzgive;
use app\common\model\CardGeneral;
use app\common\model\CardGoods;
use app\common\model\CardMember;
use app\common\model\CardOrder;
use app\common\model\CardShareRule;
use app\common\model\CardShareUser;
use app\common\model\CardStore;
use app\common\model\CardUserGet;
use app\common\model\CardRank;
use app\common\model\Agent;
use app\common\model\CardUserUpdate;
use app\common\model\OpenTemplate;
use app\common\model\Paylog;
use app\common\model\WxOpen;
use app\common\model\Merchant;
use app\common\model\System;
use Endroid\QrCode\QrCode;
use think\Controller;
use think\Session;
use Wechat\Wxobjopen;

class Cardcodes extends Mobilebase
{
    //条形码
    public function cardbarcode($arr ='704210880124', $level = 4, $size = 16)
    {
        $qrCode = new QrCode();
        $qrCode->setText($arr)
            ->setSize(570)//大小
            //->setLabelFontPath(VENDOR_PATH . 'endroid/qrcode/assets/noto_sans.otf')
            ->setErrorCorrectionLevel('high')
            ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
            ->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0));
        header('Content-Type: ' . $qrCode->getContentType());
        $image = $qrCode->writeString();
        $path = $_SERVER['DOCUMENT_ROOT'] . "/barcode/card/" . $arr . '.png';
        file_put_contents($path, $image);
        $res = request()->domain() . "/barcode/card/" . $arr . '.png';
        return $res;
    }
    
}
